{% extends "index/main.html" -%}
{% block content -%}
<div class="box-content">
	<div id="tab_form">
		<div class="group-form">
			<div class="group-label">姓名</div>
			<div class="group-content">
				<input type="text" name="name">
			</div>
			<div class="group-label">出乘日期</div>
			<div class="group-content">
				<input type="text" id="workDate" name="workDate" class="iceDate-icon">
			</div>
			<div class="group-content">
				<button type="button" onclick="query('tab', 1)" class="btn bg-royal ml20">查询</button>
				{% if has_btn(btn="editRoute", userId=userId) -%}
				<button type="button" onclick="editRoute('')" class="btn bg-royal ml20">添加</button>
				{% endif -%}
			</div>
		</div>
		<div class="group-form">
			<div class="group-label">车次</div>
			<div class="group-content">
				<select name="trains" class="sel">
					<option value=""></option>
					{% for me in trains -%}
					<option value="{{me.name}}">{{me.name}}</option>
					{% endfor -%}
				</select>
			</div>
			<div class="group-label">退乘日期</div>
			<div class="group-content">
				<input type="text" id="quitDate" name="quitDate" class="iceDate-icon">
			</div>
			<div class="group-content">
				{% if has_btn(btn="printRoute", userId=userId) -%}
				<a href="{{ctx}}/market/printRoute.html" class="btn bg-royal ml20">打印</a>
				{% endif -%}
			</div>
		</div>
	</div>
	<table id="tab" url="{{ctx}}/market/routeData.html" class="table table-border table-responsive">
		<thead>
			<tr>
				<th>序号</th>
				<th field="workDate">出乘日期</th>
				<th field="quitDate">退乘日期</th>
				<th field="trains">车次</th>
				<th field="name">销售人员</th>
				<th render="opt">操作</th>
			</tr>
		</thead>
	</table>
</div>
<div id="tab_page"></div>
<script type="text/javascript">
	ice(function() {
		iceui.use('date', function() {
			ice.date({
				id : 'workDate',
				format : 'y-m-d'
			});
			ice.date({
				id : 'quitDate',
				format : 'y-m-d'
			});
		});
		query('tab', 1);
	});

	function opt(json) {
		var url = '';
		if (bool('{{has_btn(btn="editRoute", userId=userId)}}')) {
			url += '<button type="button" onclick="editRoute(' + json.id + ')" class="btn bg-royal">编辑</button>';
		}
		return url;
	}

	function editRoute(id) {
		location.href = '{{ctx}}/market/editRoute.html?id=' + id;
	}
</script>
{% endblock content -%}
